package com.samphanie.ane.app.demo.tab

import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.samphanie.ane.app.R
import com.samphanie.ane.ui.tab.bottom.AneTabBottomInfo
import com.samphanie.ane.ui.tab.bottom.AneTabBottomLayout

class AneTabBottomDemoActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_ane_tab_bottom_demo)
//        setSupportActionBar(findViewById(R.id.toolbar))
//
//        findViewById<FloatingActionButton>(R.id.fab).setOnClickListener { view ->
//            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
//                .setAction("Action", null).show()
//        }

        initTabBottom()
    }

    private fun initTabBottom() {
        val aneTabBottomLayout: AneTabBottomLayout = findViewById(R.id.ane_tab_layout)
        aneTabBottomLayout.setTabAlpha(0.85f)
        val bottomInfoList: MutableList<AneTabBottomInfo<*>> = ArrayList()

        val homeInfo = AneTabBottomInfo(
            "首页",
            "font/iconfont.ttf",
            getString(R.string.if_home),
            null,
            "#ff656667",
            "#ffd44949"
        )

        val infoRecommend = AneTabBottomInfo(
            "收藏",
            "font/iconfont.ttf",
            getString(R.string.if_recommend),
            null,
            "#ff656667",
            "#ffd44949"
        )

        val infoCategory = AneTabBottomInfo(
            "分类",
            "font/iconfont.ttf",
            getString(R.string.if_category),
            null,
            "#ff656667",
            "#ffd44949"
        )

        val infoChat = AneTabBottomInfo(
            "推荐",
            "font/iconfont.ttf",
            getString(R.string.if_chat),
            null,
            "#ff656667",
            "#ffd44949"
        )

        val infoProfile = AneTabBottomInfo(
            "我的",
            "font/iconfont.ttf",
            getString(R.string.if_profile),
            null,
            "#ff656667",
            "#ffd44949"
        )

        bottomInfoList.add(homeInfo)
        bottomInfoList.add(infoCategory)
        bottomInfoList.add(infoChat)
        bottomInfoList.add(infoRecommend)
        bottomInfoList.add(infoProfile)

        aneTabBottomLayout.inflateInfo(bottomInfoList)
        aneTabBottomLayout.addTabSelectedChangeListener { _, _, nextInfo ->
            Toast.makeText(this@AneTabBottomDemoActivity, nextInfo.name, Toast.LENGTH_SHORT).show()
        }

        aneTabBottomLayout.defaultSelected(homeInfo)
    }
}